package com.echo.register.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.echo.register.common.result.Result;
import com.echo.register.model.user.UserInfo;
import com.echo.register.user.service.UserInfoService;
import com.echo.register.vo.user.UserInfoQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName: UserController
 * @Package: com.echo.register.user.controller
 * @Description:
 * @Author 谢同学
 * @Create 2024/1/2 21:13
 * @Version 1.0
 */
@RestController
@Api(tags = "用户信息后台管理")
@RequestMapping("/admin/user")
public class UserController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation("条件分页查询用户")
    @GetMapping("{page}/{limit}")
    public Result<Page<UserInfo>> selectPage(@PathVariable Long page,
                                            @PathVariable Long limit,
                                            UserInfoQueryVo userInfoQueryVo) {
       return Result.ok(userInfoService.selectPage(page,limit,userInfoQueryVo));
    }
    @ApiOperation("更新用户状态")
    @GetMapping("lock/{userId}/{status}")
    public Result<?> lock(@PathVariable Long userId, @PathVariable Integer status){
        userInfoService.lock(userId,status);
        return Result.ok();
    }
    @ApiOperation("用户详情")
    @GetMapping("show/{userId}")
    public Result<Map<String,Object>> show(@PathVariable Long userId){
        return Result.ok(userInfoService.show(userId));
    }

    @ApiOperation("认证审批")
    @GetMapping("approval/{userId}/{authStatus}")
    public Result<?> approval(@PathVariable Long userId,@PathVariable Integer authStatus){
        userInfoService.approval(userId,authStatus);
        return Result.ok();
    }
}
